package com.kwshare.common.core.utils;

import javax.servlet.http.HttpServletRequest;

/**
 * 权限获取工具类
 *
 * @author yangjing
 */
public class SecurityUtils {

    /**
     * 获取账号
     *
     * @param httpServletRequest httpServletRequest
     * @return 账号
     */
    public static String getUsername(HttpServletRequest httpServletRequest)
    {
        String token = httpServletRequest.getHeader("Authorization").replaceFirst("Bearer ","");
        String username = JwtUtils.getUserName(JwtUtils.parseToken(token).getBody());
        return username;
    }
}
